package com.cnyz.controller;

import com.cnyz.base.ResponseResult;
import com.cnyz.service.impl.FileUploadServiceImp;
import com.cnyz.vo.UploadVo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;


@RestController
@RequestMapping("/upload")
@ApiModel(description = "文件上传接口")

public class FileUploadController {

    @Autowired
    private FileUploadServiceImp fileUploadServiceImp;


    @PostMapping("/file")
    @ApiOperation("文件上传")
    public ResponseResult uploadFile(@RequestParam("file") MultipartFile file) {
        UploadVo uploadVo = fileUploadServiceImp.uploadFile(file);
        return ResponseResult.success("成功上传文件",uploadVo);
    }

}
